Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

Address.js ➔ describe(ꞌAddressꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 84

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 84
rs 8.7169

5 Functions

Rating   Name   Duplication   Size   Complexity  
A Address.js ➔ ... ➔ it(ꞌtoJSONꞌ) 0 16 1
B Address.js ➔ ... ➔ it(ꞌBuildꞌ) 0 25 1
A Address.js ➔ ... ➔ it(ꞌCreate plainꞌ) 0 4 1
B Address.js ➔ ... ➔ it(ꞌCreate with JSONꞌ) 0 26 1
A Address.js ➔ ... ➔ it(ꞌconstructor does not copy instancesꞌ) 0 5 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
var assert = require('chai').assert,
2
    GedcomX = require('../../');
3
4
describe('Address', function(){
5
  
6
  it('Create plain', function(){
7
    assert.instanceOf(new GedcomX.Address(), GedcomX.Address, 'An instance of Address is not returned when calling the constructor with new.');
8
    assert.instanceOf(GedcomX.Address(), GedcomX.Address, 'An instance of Address is not returned when calling the constructor without new.');
9
  });
10
  
11
  it('Create with JSON', function(){
12
    var address = GedcomX.Address({
13
      value: 'big\nstreet\naddress',
14
      city: 'big city',
15
      country: 'COUNTRY',
16
      postalCode: '98765',
17
      stateOrProvince: 'ST',
18
      street: 'a street',
19
      street2: '2nd street',
20
      street3: '3rd street',
21
      street4: 'no way',
22
      street5: 'high way',
23
      street6: 'wow'
24
    });
25
    assert.equal(address.getValue(), 'big\nstreet\naddress');
26
    assert.equal(address.getCity(), 'big city');
27
    assert.equal(address.getCountry(), 'COUNTRY');
28
    assert.equal(address.getPostalCode(), '98765');
29
    assert.equal(address.getStateOrProvince(), 'ST');
30
    assert.equal(address.getStreet(), 'a street');
31
    assert.equal(address.getStreet2(), '2nd street');
32
    assert.equal(address.getStreet3(), '3rd street');
33
    assert.equal(address.getStreet4(), 'no way');
34
    assert.equal(address.getStreet5(), 'high way');
35
    assert.equal(address.getStreet6(), 'wow');
36
  });
37
  
38
  it('Build', function(){
39
    var address = GedcomX.Address()
40
      .setValue('big\nstreet\naddress')
41
      .setCity('big city')
42
      .setCountry('COUNTRY')
43
      .setPostalCode('98765')
44
      .setStateOrProvince('ST')
45
      .setStreet('a street')
46
      .setStreet2('2nd street')
47
      .setStreet3('3rd street')
48
      .setStreet4('no way')
49
      .setStreet5('high way')
50
      .setStreet6('wow');
51
    assert.equal(address.getValue(), 'big\nstreet\naddress');
52
    assert.equal(address.getCity(), 'big city');
53
    assert.equal(address.getCountry(), 'COUNTRY');
54
    assert.equal(address.getPostalCode(), '98765');
55
    assert.equal(address.getStateOrProvince(), 'ST');
56
    assert.equal(address.getStreet(), 'a street');
57
    assert.equal(address.getStreet2(), '2nd street');
58
    assert.equal(address.getStreet3(), '3rd street');
59
    assert.equal(address.getStreet4(), 'no way');
60
    assert.equal(address.getStreet5(), 'high way');
61
    assert.equal(address.getStreet6(), 'wow');
62
  });
63
  
64
  it('toJSON', function(){
65
    var data = {
66
      value: 'big\nstreet\naddress',
67
      city: 'big city',
68
      country: 'COUNTRY',
69
      postalCode: '98765',
70
      stateOrProvince: 'ST',
71
      street: 'a street',
72
      street2: '2nd street',
73
      street3: '3rd street',
74
      street4: 'no way',
75
      street5: 'high way',
76
      street6: 'wow'
77
    }, address = GedcomX.Address(data);
78
    assert.deepEqual(address.toJSON(), data);
79
  });
80
  
81
  it('constructor does not copy instances', function(){
82
    var obj1 = GedcomX.Address();
83
    var obj2 = GedcomX.Address(obj1);
84
    assert.strictEqual(obj1, obj2);
85
  });
86
  
87
});